<template>
  <div>
    <div v-for="(item, index) in treeData" :key="index" class="mg_t10">
      <div class="tree-item" @click="chose(item, treeData)">
        <span>
          <a-icon type="user" />
          {{ item.name }}
        </span>
        <a-icon v-if="item.isSelected" type="check" />
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: "TreeNode",
  props: {
    treeData: {
      type: Array,
      default: () => []
    }
  },
  methods: {
    chose(item, data) {
      item.isSelected = !item.isSelected;
      this.$emit("change", item);
    }
  }
};
</script>
<style lang="scss" scoped>
.tree-item {
  display: flex;
  justify-content: space-between;
  flex-direction: row;
  align-items: center;
  cursor: pointer;
}
</style>
